/*
 *  POJ3016: Subsequence
 */

/*-------- Includes --------*/
#include <iostream>
#include <algorithm>

using namespace std;

/*-------- Defines --------*/


/*-------- Types --------*/


/*-------- Global Variables --------*/
int N, S;
int a[100000];

/*-------- Function Prototypes --------*/


/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int nCase;

    cin >> nCase;

    while (nCase--) {
        cin >> N >> S;

        for (int i = 0; i < N; i++) cin >> a[i];

        int i = 0, j = 0;
        int sum = 0;
        int Min = N + 1;
        while (true) {
            while (j < N && sum < S)
                sum += a[j++];

            if (sum < S) break;

            // update Min
            Min = min(Min, j - i);

            while (sum >= S) sum -= a[i++];

            // update Min
            Min = min(Min, j - i + 1);
        }

        if (Min > N) cout << 0 << endl;
        else         cout << Min << endl;
    }

    return 0;
}

/*-------- Functions --------*/

